import { useState } from 'react';
import { Button, Space, message } from 'antd';
import { authHttp } from '@/utils/request';

function foo() {
	return authHttp.get({
		url: '/auth/test'
	});
}

const Cancel = () => {
	const [loading, setLoading] = useState(false);

	const bar = async () => {
		setLoading(true);
		const res = await foo().finally(() => setLoading(false));
		console.log(res);
		message.success('success');
	};
	const cancel = () => {
		authHttp.cancelRequest('/auth/test');
	};
	return (
		<Space>
			<Button type="primary" loading={loading} onClick={bar}>
				发送
			</Button>
			<Button danger onClick={cancel}>
				取消
			</Button>
		</Space>
	);
};

export default Cancel;
